/* 
 * File:   Compiler.h
 * Author: itu
 *
 * Created on November 26, 2011, 9:49 PM
 */

#include "Terminal.h"
#include "Nonterminal.h"
#include "State.h"
#include <vector>
#include "TableNode.h"
#include "LineOperator.h"

#ifndef COMPILER_H
#define	COMPILER_H

using namespace std;

class Compiler {
public:
    Compiler();
    void printNonterminal();
    void printTerminal();
    void printNonterminalRules();
    void printNonterminalFirst();
    void printNonterminalFollow();
    void printStates();
    Nonterminal* getNonterminalByIdentifier(string);
    Terminal* getTerminalByIdentifier(string);
    void findNonterminalsFollow();
    Nonterminal* getStartNonterminal();
    void createDFA();
    void addStateToStates(State *);
    bool findPossibleGoTosForGivenState(State *);
    void findAllGoTos();
    void printParserTable();
    int countRuleNumber();
    
    Operation getOperationAt(Symbol *, State *);
    void* getKeyAt(Symbol *, State *);
    void parseInput(string);
private:
    vector<Nonterminal*> nonTerminals;
    vector<Terminal*>    terminals;
    vector<State*> states;
    Symbol* dolarSymbol; //$
    Symbol* nullSymbol;  //€
    int stateNumber;
    int ruleNumber; //Kuralların sayısını tutar sayı = ruleNumber +1
    vector<TableNode*> parserTable;
    vector<Symbol*> symbolsStack; //Sembollerin tutulacağı stack;
    vector<State*> statesStack; //Statelerin tutulacağı stack;
    LineOperator *lo;
};

#endif	/* COMPILER_H */

